package com.hjf.web.servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.commons.web.servlet.BaseServlet;
import com.commons.po.Customer;

public class BottomServlet extends BaseServlet {
<<<<<<< HEAD
	private int num;
	private List<Customer> list=new ArrayList<Customer>();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		this.doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		Customer currUser=this.getCurrUser(req.getSession());
		String opr=req.getParameter("load");
		if("login".equals(opr)){
			if(currUser!=null){
				boolean isFlag=true;
				for(Customer user:list){
					if(user.getCustomer_id()==currUser.getCustomer_id()){
						isFlag=false;
					}
				}
				if(isFlag){
					list.add(currUser);
					num++;
				}
			}
		}else{
			for(Customer user:list){
				if(user.getCustomer_id()==currUser.getCustomer_id()){
					list.remove(currUser);
					num--;
				}
			}
		}
		System.out.println(num);
		req.setAttribute("onlineNum", num);
		req.getRequestDispatcher("/jsp/sys/bottom/bottom_list.jsp").forward(req, resp);
	}	
=======
	public static int num;
	private List<Customer> list=new ArrayList<Customer>();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		this.doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		Customer currUser=this.getCurrUser(req.getSession());
		String opr=req.getParameter("load");
		if("login".equals("login")){
			if(currUser!=null){
				boolean isFlag=true;
				for(Customer user:list){
					if(user.getCustomer_id()==currUser.getCustomer_id()){
						isFlag=false;
					}
				}
				if(isFlag){
					list.add(currUser);
					num++;
				}
			}
		}else{
			for(Customer user:list){
				if(user.getCustomer_id()==currUser.getCustomer_id()){
					list.remove(currUser);
					num--;
				}
			}
		}
		System.out.println("进入serverlet");
		System.out.println(num);
		req.setAttribute("onlineNum", num);
		req.getRequestDispatcher("/jsp/sys/bottom/bottom_list.jsp").forward(req, resp);
	}

	public static  int getInt(){
		return num;
	}
>>>>>>> branch 'master' of https://gitee.com/threePokeMan/OAAuthority.git

}
